package chatroom18;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.SocketException;
import java.net.UnknownHostException;

public class ServerParent1 extends Thread {
	protected static DatagramSocket outSocket = null;
	
	protected static InetAddress group; 

    
    public ServerParent1(String string) {
		// TODO Auto-generated constructor stub
    	super(string);
	}


	public static void main(String[] args) throws IOException 
    {
    	int count = 1;
    	boolean listening = true;
    	outSocket = new DatagramSocket(4445);
    	try {
			group = InetAddress.getByName("230.0.0.1");
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		ServerSocket inSocket = null;
		try {
			inSocket = new ServerSocket(4444);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("About to listen");
    	while (listening)
    	{
    		new ServerChild(inSocket.accept()).start();
    		System.out.println("Child # " + count + " has begun, believes the parent");
    		count++;
    	}
    	
    	inSocket.close();
    	outSocket.close();
    		
    }
}
